#ifndef CONFIGMANAGER_H
#define CONFIGMANAGER_H

#include <QObject>
#include <QVariantMap>
#include <QSettings>

class ConfigManager : public QObject
{
    Q_OBJECT

public:
    explicit ConfigManager(QObject *parent = nullptr);
    ~ConfigManager();
    
    // 配置获取和设置
    QVariant getValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
    void setValue(const QString &key, const QVariant &value);
    
    // 批量操作
    QVariantMap getAllConfig() const;
    void setConfig(const QVariantMap &config);
    
    // 配置组操作
    void beginGroup(const QString &group);
    void endGroup();
    
    // 预定义配置项
    enum ConfigKey {
        // 连接设置
        LastHost,
        LastPort,
        LastUsername,
        LastProtocol,
        
        // 显示设置
        FullscreenMode,
        MultiScreenSupport,
        RendererType,
        
        // 性能设置
        TargetFps,
        QualityLevel,
        CompressionLevel,
        
        // 功能设置
        ClipboardSync,
        AudioSupport,
        FileTransfer,
        
        // 界面设置
        Language,
        Theme,
        WindowGeometry
    };
    
    // 快速访问常用配置
    QString getLastHost() const;
    void setLastHost(const QString &host);
    
    int getLastPort() const;
    void setLastPort(int port);
    
    bool getFullscreenMode() const;
    void setFullscreenMode(bool fullscreen);
    
    int getTargetFps() const;
    void setTargetFps(int fps);

private:
    QSettings *settings;
    QVariantMap cache;
    bool cacheEnabled;
};

#endif // CONFIGMANAGER_H